package com.ming_za.od_updater;

import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Config(modid = ODUpdaterMod.MOD_ID)
@Config.LangKey("初梦更新器配置")
public class ODModConfig {

    @Config.Comment("更新服务器ip-例如：127.0.0.1:26666")
    @Config.LangKey("更新服务器ip")
    public static String serverIp = "127.0.0.1:26666";

    @Config.Comment("资源标签id-通过初梦更新器后台获取，用于区别该更新功能可以更新的资源")
    @Config.LangKey("资源标签id")
    public static String resLabel = "0";

    @Config.Comment("未发布密钥-通过初梦更新器后台获取,一般情况设为0即可")
    @Config.LangKey("未发布密钥")
    public static int unpublishKey = 0;

    @Config.Comment("更新根目录-仅支持.minecraft以内的目录，默认为\".\"表示以.minecraft目录作为根目录，如果你需要以mods作为根目录，填写\"./mods\"即可")
    @Config.LangKey("更新根目录")
    public static String rootDir = ".";

    @Config.Comment("开启debug调试")
    @Config.LangKey("开启debug")
    public static boolean debug = false;

    @Mod.EventBusSubscriber(modid = ODUpdaterMod.MOD_ID)
    private static class EventHandler {
        @SubscribeEvent
        public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
            if (event.getModID().equals(ODUpdaterMod.MOD_ID)) {
                ConfigManager.sync(ODUpdaterMod.MOD_ID, Config.Type.INSTANCE);
            }
        }
    }

}
